using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;

namespace Common.Core.Configuration
{
	public class ConfigurationView<SettingsType> where SettingsType : ConfigurationSection
	{
		readonly IConfigurationSource source;

		public ConfigurationView() : this( ConfigurationSourceFactory.Create() )
		{}

		public ConfigurationView( IConfigurationSource source )
		{
			this.source = source;
		}

		protected SettingsType Settings
		{
			get { return settings ?? ( settings = ConfigurationSettings.Retrieve<SettingsType>( source ) ); }
		}	SettingsType settings;
	}
}